package com.elong.businesstravel.protocol.order;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONObject;

import com.elong.businesstravel.entitys.OrderInfo;
import com.elong.businesstravel.protocol.baseresponse.BaseELongJsonHttpResponse;

public class GetMemberOrderResponse extends BaseELongJsonHttpResponse {

	public List<OrderInfo> orderInfos = new ArrayList<OrderInfo>();
	public int count = 0;
	 
	@Override
	public void onSuccess(int statusCode, Header[] headers,
			JSONObject mainJsonObject) throws Throwable {
		JSONObject responseJsonObject = mainJsonObject.optJSONObject("response");
		count = responseJsonObject.optInt("count");
		JSONArray infoJsonArray = responseJsonObject.optJSONArray("info");
		for (int i = 0; i < infoJsonArray.length(); i++) {
			JSONObject itemInfoJsonObject = infoJsonArray.optJSONObject(i);
			OrderInfo orderInfo = new OrderInfo();
			orderInfo.elongorderid = itemInfoJsonObject.optString("elongorderid", "");
			orderInfo.elonghotelid = itemInfoJsonObject.optString("elonghotelid", "");
			orderInfo.orderid = itemInfoJsonObject.optString("orderid", "");
			orderInfo.createtime = itemInfoJsonObject.optString("createtime", "");
			orderInfo.orderstate = itemInfoJsonObject.optString("orderstate", "");
			orderInfo.hotelname = itemInfoJsonObject.optString("hotelname", "");
			orderInfo.phone = itemInfoJsonObject.optString("phone", "");
			orderInfo.address = itemInfoJsonObject.optString("address", "");
			orderInfo.roomname = itemInfoJsonObject.optString("roomname", "");
			orderInfo.roomnum = itemInfoJsonObject.optString("roomnum", "");
			orderInfo.contactname = itemInfoJsonObject.optString("contactname", "");
			orderInfo.contactmobile = itemInfoJsonObject.optString("contactmobile", "");
			orderInfo.startdate = itemInfoJsonObject.optString("startdate", "");
			orderInfo.enddate = itemInfoJsonObject.optString("enddate", "");
			orderInfo.latestarrival = itemInfoJsonObject.optString("latestarrival", "");
			orderInfo.totalprice = itemInfoJsonObject.optString("totalprice", "");
			orderInfo.totalbonus = itemInfoJsonObject.optString("totalbonus", "");
			orderInfo.googlelat = itemInfoJsonObject.optString("googlelat", "");
			orderInfo.googlelon = itemInfoJsonObject.optString("googlelon", "");
			orderInfo.cancel = itemInfoJsonObject.optString("cancel", "");
			orderInfo.notice = itemInfoJsonObject.optString("notice", "");
			/**17已结账*/
			orderInfo.statusnum = itemInfoJsonObject.optString("statusnum","");//17已结账
			/**0 不能 1 能*/
			orderInfo.canvoice = itemInfoJsonObject.optString("canvoice","");
			/**是否存在音频，0不存在，1存在*/
			orderInfo.isvoice = itemInfoJsonObject.optString("isvoice","");//是否存在音频，0不存在，1存在
			orderInfo.voiceurl = itemInfoJsonObject.optString("voiceurl","");
			orderInfo.voicetime = itemInfoJsonObject.optString("voicetime","");
			JSONObject shareinfoJsonObject = itemInfoJsonObject.optJSONObject("shareinfo");
			orderInfo.mShareInfo.imageurl = shareinfoJsonObject.optString("imageurl", "");
			orderInfo.mShareInfo.content = shareinfoJsonObject.optString("content", "");
			orderInfo.mShareInfo.title = shareinfoJsonObject.optString("title", "");
			orderInfo.mShareInfo.shareurl = shareinfoJsonObject.optString("shareurl");
			JSONObject shortshareJsonObject = itemInfoJsonObject.optJSONObject("shareinfo");
			orderInfo.mShortShare.imageurl = shortshareJsonObject.optString("imageurl", "");
			orderInfo.mShortShare.content = shortshareJsonObject.optString("content", "");
			orderInfo.mShortShare.title = shortshareJsonObject.optString("title", "");
			orderInfo.mShortShare.shareurl = shortshareJsonObject.optString("shareurl");
			orderInfos.add(orderInfo);
		}
	}

}
